interface _CA_ {
    /**
     * 替换指定位置的值
     * @param arr 数组
     * @param index 指定位置
     * @param value 值
     * @param deepClone <false> true: 修改深度克隆的新数组; false: 修改浅克隆的新数组; null: 直接修改原数组;
     * @returns true: 包含该值; false: 不包含该值;
     */
    replace(arr: Array<any>, index: number, value: any, deepClone?: null | boolean): Array<any>;
}
{
    const replace = U.F.overloading('Array-replace',
        {
            types: [Etype.array, Etype.number, U.F.argType.any, U.F.argType.optional(Etype.undefined)],
            fn: function (arr: any, index: any, value: any, deepClone: any) {
                return replace(arr, index, value, false);
            }
        },
        {
            types: [Etype.array, Etype.number, U.F.argType.any, Etype.boolean],
            fn: function (arr: any, index: any, value: any, deepClone: any) {
                const result = deepClone ? U.clone(arr) : [...arr];
                result[index] = value;
                return result;
            }
        },
        {
            types: [Etype.array, Etype.number, U.F.argType.any, Etype.null],
            fn: function (arr: any, index: any, value: any, deepClone: any) {
                arr[index] = value;
                return arr;
            }
        },
    );

    Object.defineProperty(_CA_.prototype, 'replace', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: replace
    });
}
